public class Demo1 {
    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,5,6};
        int n = arr.length;
        int[] ret = new int[n];

        int j = 0;
        for(int i = 0;i < arr.length;i++){
            if(arr[i] % 2 == 1){
                ret[j++] = arr[i];
            }
        }
        for(int i = 0;i < arr.length;i++){
            if(arr[i] % 2 == 0){
                ret[j++] = arr[i];
            }
        }

        for(int i = 0;i < arr.length;i++){
            System.out.print(ret[i] + " ");
        }
        System.out.println();
    }
}
